<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
    <title>登录界面</title>
    <!--引入elementui得样式-->
    <link type="text/css" rel="stylesheet" href="/css/index.css"/>
    <!--引入vue得依赖必须再elementui之前引入vue-->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/qs.min.js"></script>
</head>
<body style="background-image: url(img/背景图.jpg);background-repeat: no-repeat;background-attachment: fixed;background-size: 100% 100%;";>
<div id="login" class="beijing">
    <div class="tou"><h2><span>欢迎进入AAA大医院预约系统</span></h2></div>
    <div id="loginBox">
        <el-form :label-position="labelPosition" :model="loginForm" status-icon :rules="loginRules" ref="ruleForm"  label-width="80px" class="demo-ruleForm" id="loginForm">
            <el-form-item style="font-weight: bolder" label="账号:" prop="phoneNumber">
                <el-input type="text" v-model="loginForm.phoneNumber" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item style="font-weight: bolder" label="密码:" prop="password">
                <el-input type="password" v-model="loginForm.password" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button class="d" type="primary" @click="login()">登录</el-button>
                <el-button class="z" @click="zc()">注册</el-button>
            </el-form-item>
        </el-form>
    </div>
</div>
</body>
<script>
    var app=new Vue({
        el:"#login",
        data:{
            //登录的表单对象
            loginForm:{phoneNumber:"",password:""},
            labelPosition:'left',
            //登录的规则
            loginRules:{
                phoneNumber:[
                    { required: true, message: '请输入账号', trigger: 'blur' },
                ],
                password:[
                    { required: true, message: '请输入密码', trigger: 'blur' },
                ]
            }
        },
        methods:{
            login(){
                this.$refs.ruleForm.validate((valid) => {
                    if(valid){
                        axios.post("/user/user",this.loginForm).then(resp=>{
                            if(resp.data.code===200){
                                this.$message.success("登录成功");
                                location.href="/department.html";
                            }else{
                                this.$message.error("登录失败");
                            }
                        })
                    }
                })
            },
            zc(){
                location.href="/registration.html"
            }
        }
    })
</script>

<style>
    #login{
        width: 450px;
        height: 280px;
        margin: 100px auto;
        border: 2px solid gainsboro;
        background-color: rgba(0, 0, 0, 0.1);
    }
    #loginBox{
        margin: 0px 40px 25px 40px;
    }
    #loginForm{
        margin: 20px auto;
    }
    .tou{
        height:40px;
        line-height:40px;
        text-align: center
    }
    .d{
        margin-left: 38px;
    }
    .z{
        margin-left: 20px;
        margin-right: 80px;
    }
</style>
</html>